<template>
	<view class="select-voucher-list">
		<scroll-view scroll-y="true">
			<view class="select-voucher-item" v-for="item in list" :key="item.voucherid"
				@click="() => voucherSelect(item)">
				<u-image v-if="item.goodsimg" :src="item.goodsimg" mode="" width="130rpx" height="130rpx"
					border-radius="12"></u-image>
				<u-image v-else src="@/static/image/logo.png" mode="" width="130rpx" height="130rpx"
					border-radius="12"></u-image>
					
					
				<view class="select-voucher-item-right">
					<view class="select-voucher-item-text">
						{{item.goodsname}}
					</view>
					<view class="select-voucher-item-desc">
						{{item.vouchercode}}
					</view>
				</view>
				<view class="select-voucher-footer">
					去使用
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
			}
		},
		onShow() {
			this.loadVoucher()
		},
		methods: {
			loadVoucher() {
				this.$u.api
					.postFindVaildVoucherList({
						page: 1,
						rows: 999
					}).then(res => {
						this.list = res.data.rows
					})
			},
			voucherSelect(item) {
				uni.navigateTo({
					url: `/pages/index/confirm-order/confirm-order?voucherid=${item.voucherid}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.select-voucher-list {
		width: 100vw;
		background-color: #f9f9f9;
		height: 100vh;
	}

	.select-voucher-item {
		display: flex;
		padding: 26rpx;
		box-shadow: 0px 0px 13px -2px rgba(0, 0, 0, 0.26);
		margin: 35rpx 30rpx;
		border-radius: 24rpx;
		box-sizing: border-box;
		position: relative;
		background-color: #fff;

		&-text {
			flex: 1;
			
			font-size: 32rpx;
			font-weight: 900;
		}
		
		&-right {
			padding-left: 20rpx;
		}
		
		&-desc {
			margin-top: 10rpx;
			font-size: 28rpx;
			color: #888;
		}

		&-active {
			border: solid 1rpx red;
		}
	}
	.select-voucher-footer {
		position: absolute;
		right: 25rpx;
		bottom: 25rpx;
		background-color: #3D9C9A;
		width: 140rpx;
		height: 50rpx;
		border-radius: 35rpx;
		color: #fff;
		box-sizing: border-box;
		text-align: center;
		line-height: 50rpx;
		font-size: 25rpx;
	}
</style>